from django.shortcuts import render
from django.http import HttpResponse
from .. models import Users,Order

def orderlist(request):
    obs = Order.objects.filter()
    context = {'olist':obs}
    return render(request,'admin/orderlist.html',context)

#会员编辑
def orderedit(request,oid):
    #获取会员对象
    ob = Order.objects.get(id=oid)
    if request.method == 'GET':
        #分配数据
        context = {'info':ob}
        return render(request,'admin/orderedit.html',context)
    elif request.method == 'POST':

        ob.status = request.POST['status']
        ob.save()
        return HttpResponse('<script>alert("更新成功");location.href="/myadmin/order/list/"</script>')
    
    #解析模板